package net.hcpme.adapter;

import java.util.List;

import net.hcpme.activity.R;
import net.hcpme.dao.TacticsContentDataDao;
import net.hcpme.dao.TacticsContentViewDao;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class TacticsAdapter extends BaseAdapter {
	
	private List<TacticsContentDataDao> tacContentDaoList;
	private LayoutInflater inflater;
	

	public TacticsAdapter(List<TacticsContentDataDao> tacContentDaoList,
			LayoutInflater inflater) {
		super();
		this.tacContentDaoList = tacContentDaoList;
		this.inflater = inflater;
	}



	@Override
	public int getCount() {
		return tacContentDaoList.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TacticsContentViewDao holder = null;
		if(convertView ==null){
			holder = new TacticsContentViewDao();
			convertView = inflater.inflate(R.layout.tactics_msg_item, null);
			holder.setHeadImg((ImageView)convertView.findViewById(R.id.userhead));
			holder.setCompressTypeView((TextView)convertView.findViewById(R.id.comperetype));
			holder.setCompressNameView((TextView)convertView.findViewById(R.id.comperename));
			holder.setDateAndTimeView((TextView)convertView.findViewById(R.id.timeanddate));
			holder.setTacticsItemTitleView((TextView)convertView.findViewById(R.id.tacticstitle));
			holder.setTacticsItemContentView((TextView)convertView.findViewById(R.id.tacticscontent));
			holder.setTacticsItemImg((ImageView)convertView.findViewById(R.id.tacticscimg));
			convertView.setTag(holder);
		}else{
			holder = (TacticsContentViewDao)convertView.getTag();
		}
		    holder.getHeadImg().setBackgroundResource(R.drawable.apple);//default
		    holder.getCompressTypeView().setText(R.string.compere);
		    holder.getCompressNameView().setText(R.string.comperename);
		    holder.getDateAndTimeView().setText(R.string.datetimedefault);
		    holder.getTacticsItemTitleView().setText(R.string.tactics_title_default);
		    holder.getTacticsItemContentView().setText(R.string.tactics_content_default);
		    holder.getTacticsItemImg().setImageResource(R.drawable.u66_normal);
		    holder.getTacticsItemImg().setOnClickListener(new View.OnClickListener() {
				
				@Override
				public void onClick(View v) {
					//放大图片
				}
			});
		    
		return convertView;
	}

}
